home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: rmemfix.ri - memory management functions for fixed regions
- * Contents: initalloc, reclaim
- */
-
- /*
- * Prototype.
- */
-
- hidden novalue reclaim Params((int region));
-
- /*
- * initalloc - initialization routine to allocate memory regions
- */
-
- #if COMPILER
- novalue initalloc()
- {
- static char dummy[1]; /* dummy static region */
-
- #else /* COMPILER */
- novalue initalloc(codesize)
- word codesize;
- {
- static char dummy[1]; /* dummy static region */
-
- if (codesize > (unsigned)MaxBlock)
- error("icode file too large");
- /*
- * Allocate icode region
- */
- if ((code = (char *)AllocReg(codesize)) == NULL)
- error("insufficient memory for icode");
- #endif /* COMPILER */
-
- /*
- * Set up allocated memory. The regions are:
-
- * Static memory region (not used)
- * Allocated string region
- * Allocate block region
- * Qualifier list
- */
-
- statend = statfree = statbase = dummy;
- #ifdef MultiRegion
- {
- uword t1, t2;
- t1 = ssize;
- t2 = abrsize;
- curstring = (struct region *)malloc(sizeof(struct region));
- curblock = (struct region *)malloc(sizeof(struct region));
- curstring->size = t1;
- curblock->size = t2;
- }
- curstring->next = curstring->prev = NULL;
- curstring->Gnext = curstring->Gprev = NULL;
- curblock->next = curblock->prev = NULL;
- curblock->Gnext = curblock->Gprev = NULL;
- #endif /* MultiRegion */
- if ((strfree = strbase = (char *)AllocReg(ssize)) == NULL)
- error("insufficient memory for string region");
- strend = strbase + ssize;
- if ((blkfree = blkbase = (char *)AllocReg(abrsize)) == NULL)
- error("insufficient memory for block region");
- blkend = blkbase + abrsize;
- if ((quallist = (dptr *)AllocReg(qualsize)) == NULL)
- error("insufficient memory for qualifier list");
- equallist = (dptr *)((char *)quallist + qualsize);
- }
-
- /*
- * reclaim - reclaim space in the allocated memory regions. The marking
- * phase has already been completed.
- */
-
- static novalue reclaim(region)
- int region;
- {
- /*
- * Collect available co-expression blocks.
- */
- cofree();
-
- /*
- * Collect the string space leaving it where it is.
- */
- if (!qualfail)
- scollect((word)0);
-
- /*
- * Adjust the blocks in the block region in place.
- */
- adjust(blkbase,blkbase);
-
- /*
- * Compact the block region.
- */
- compact(blkbase);
- }
-